//
//  UIScrollerView+Ext.swift
//  CocoProject
//
//  Created by Vill on 2023/11/3.
//

import Foundation
import MJRefresh

extension UIScrollView{
    
    func headerStartRefreshing(){
        self.mj_header?.beginRefreshing()
    }
    
    func headerRefresh(block:@escaping (()->Void)){
        self.mj_header = MJRefreshNormalHeader.init(refreshingBlock: {
            block()
        })
    }
    
    func headerEndRefreshing(){
        self.mj_header?.endRefreshing()
    }
    
    func footerRefresh(block:@escaping (()->Void)){
        self.mj_footer = MJRefreshAutoNormalFooter.init(refreshingBlock:{
            block()
        })
    }
    
    func footerEndRefreshing(_ noMore:Bool = false){
        self.mj_footer?.isHidden = noMore
        if noMore {
            self.mj_footer?.endRefreshingWithNoMoreData()
        }else {
            self.mj_footer?.endRefreshing()
        }
    }
}

